import pandas as pd
import numpy as np
import easygui as gui

df = pd.read_csv("F:/成信大/数据挖掘与分析/朴素贝叶斯/20211129.txt", encoding="utf-8")
# 获取列数
columns = df.shape[1]
print(columns)
# 算好瓜与坏瓜的概率
col = df.columns[1:columns]
print(col[columns - 2])
# 好瓜、不好的瓜分别是多少
parameters = df[col]
conditions = {}
# 使用字典的形式存入各个类别
for i in col[: columns - 2]:
    conditions[i] = np.unique(parameters[i].values)
# 获取所有元素下标
index = conditions.keys()
# 存入用户选择的类别
temp = []
j = 0
# for i in index:
#     while j < len(conditions[i]):
#         temp.append(gui.choicebox(msg=i, choices=conditions[i], title="请选择特征"))
#         break
# for t in range(len(temp)):
#     if temp[t] is None:
#         raise Exception(print("条件漏选，无法分析结果。"))
# print(",".join(temp))
